package tnp.page;

import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;

import org.apache.log4j.Logger;

import com.google.inject.Inject;

import tnp.service.CommonService;

/**
 */
public class ItemMaster extends WebPage 
{

	private static final long serialVersionUID = 1L;
	private static Logger log = Logger.getLogger( ItemMaster.class ); 

	@Inject
	private CommonService service;

    /**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
    public ItemMaster(final PageParameters parameters) 
	{

		final TextField<String> item =
			new TextField<String>("item", new Model<String>());

		final TextField<String> itemCode =
			new TextField<String>("itemCode", new Model<String>());

    	final Form<Component> form = new Form<Component>("form");
		final Button submit = new Button("submit") 
		{
			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit() 
			{
				String inputItemCode = itemCode.getModelObject();
				String inputItem = item.getModelObject();
				service.entryItem(inputItemCode,inputItem);
			}
		};

    	form.add(item);
    	form.add(itemCode);
    	form.add(submit);
    	add(form);
    }

}
